﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Vit.Common;

namespace Vit.Web
{
    public class UnityDependencyResolver : System.Web.Mvc.IDependencyResolver
    {
        private IUnityContainer container;

        public UnityDependencyResolver()
            : this(Unity.Current)
        {
        }

        public UnityDependencyResolver(IUnityContainer container)
        {
            this.container = container;
        }

        #region IDependencyResolver Members

        public object GetService(Type serviceType)
        {
            return container.ResolveOne(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return container.ResolveAny(serviceType);
        }

        #endregion
    }
}
